<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/8/1 0001
  Time: 14:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ include file="/WEB-INF/page/include/taglib.jsp"%>
<%  String path =request.getContextPath();
    String realpath =request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8">
    <title>黑科技轮播图</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <link rel="stylesheet" href="${ctx }/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${ctx }/css/font_eolqem241z66flxr.css" media="all" />
    <link rel="stylesheet" href="${ctx }/css/list.css" media="all" />

    <script>
        var ctx = "${ctx}";
    </script>
</head>
<body class="childrenBody">
<form class="layui-form" style="width: 80%;margin-top: 20px;" enctype="multipart/form-data">




    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
            <img src="${ctx}/uploads/tu.png" id="the_image" width="200">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <button type="button" class="layui-btn" id="test1">
            <i class="layui-icon">&#xe67c;</i>上传图片
        </button>
        <%--<button type="button" class="layui-btn layui-btn-normal" id="test8">--%>
            <%--<i class="layui-icon">&#xe654;</i>选择文件--%>
        <%--</button>--%>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片地址</label>
        <div class="layui-input-block">
            <input type="text" id="image" class="layui-input userName"
                   lay-verify="required" placeholder="请输入图片地址" name="image" value="">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片链接</label>
        <div class="layui-input-block">
            <input type="text" id="link" class="layui-input userName"
                   lay-verify="required" placeholder="请输入图片链接" name="link" value="">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片序号</label>
        <div class="layui-input-block">
            <input type="text" id="sort" class="layui-input userName"
                   lay-verify="required" placeholder="请输入图片序号" name="sort" value="">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addBanner">立即提交</button>
        </div>
    </div>

</form>
<script type="text/javascript" src="${ctx }/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="${ctx }/layui/layui.js"></script>
<script type="text/javascript" src="${ctx }/page/jieqianbanners/addKZBAR.js"></script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            accept:'images'
            ,elem: '#test1' //绑定元素
            ,url: ctx+'/upload/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#the_image').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                if(res.code > 0){
                    return layer.msg('上传失败');
                }else {
                    $("#image").val(res.data);
                    layer.msg("上传成功")
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });

        // upload.render({
        //     elem: '#test8'
        //     ,url: '/uploads/'
        //     ,auto: false
        //     //,multiple: true
        //     //,bindAction: '#test9'
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#the_image').attr('src', result); //图片链接（base64）
        //             $("#image").val(res.data);
        //         });
        //     }
        //     ,done: function(res){alert(res);
        //         //console.log(res)
        //         $("#image").val(res.data);
        //     }
        // });
    });
</script>

</body>
</html>
